<template>
    <div class="mymg-tb">
        <div class="bor inleft" @click="substring">-</div>
        <div class="bor incenter" v-text="count"></div>
        <div class="bor inright" @click="addend">+</div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            count: 1     //商品数量默认为1
        }
    },
    methods: {
        substring() {
            this.count--;
            if (this.count < 1) {
                this.count = 1;               
            }
             this.getmessage();
        },
        addend() {
            this.count++;
            this.getmessage();
        },
        getmessage() {
            this.$emit('count', this.count);
        }
    }
}
</script>

<style scoped>
.mymg-tb {
    position: absolute;
    left: 100px;
    top: -3px;
}

.bor {
    width: 50px;
    height: 25px;
    text-align: center;
    float: left;
    line-height: 25px;
    margin: 0px 2px;
    border: 1px solid #099;
}
</style>